// pages/details/details.js
import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    details: '',
    picture: "",
    date: ""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(JSON.parse(options.details))
    var date = JSON.parse(options.details).billDate.split("T")[0]
    this.setData({
      details: JSON.parse(options.details),
      date
    })

  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },
  delete(e) {
    var billId = e.currentTarget.dataset.id
    console.log(billId)
    Dialog.confirm({
      title: '是否确定删除',
      // message: '弹窗内容',
    })
      .then(() => {
        wx.request({
          url: 'http://127.0.0.1:8181/bill/deleteBill?billId=' + billId,
          success(res) {
            wx.navigateBack({
              delta: 1,
            })
          }
        })
      })
      .catch(() => {
        // on cancel
      });

  },
  modify(e) {
    var details = e.currentTarget.dataset.details
    wx.navigateTo({
      url: '../modify/modify?details=' + JSON.stringify(details),
    })
  }
})